/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Business;

import Objects.Manager;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Nguyen Kim Manh
 */
public class ManagerBusiness {

     /**
     * Method isManager used to check Manager's Account when each manager login
     * @return a variable has boolean type
     * @param objManager
     */
    public static boolean isManager(Manager m) throws SQLException, ClassNotFoundException {
        boolean kt = false;

        String sql = "{call Check_LoginManager (?,?) }";

        ArrayList<String> listParam = new ArrayList<>();

        listParam.add(m.getManagerAccount());
        listParam.add(m.getManagerPass());

        ResultSet rs = DBAccess.DB_Connect.executeQuery(sql, listParam);
        
        kt = rs.next();
     
        return kt;
    }
    

    /**
     * this method used to update new password--
     */
    public static int changePassword(String acc,String pass){
        int kt=0;
        
        String sql="{call sp_ChangePasswordManager(?,?)}";
        ArrayList list=new ArrayList();
        list.add(acc);
        list.add(pass);
        try {
            kt=DBAccess.DB_Connect.executeNonQuery(sql, list);
        } catch (SQLException ex) {
            Logger.getLogger(EmployeeBusiness.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(EmployeeBusiness.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        return kt;
    }
}
